#include "cmdfmt.h"

CommandFormat::CommandFormat()
{

}

unsigned int CommandFormat::getPriority()
{
	return priority_;
}

bool CommandFormat::addWordFormat(const char *format)
{
	WordFormat wf;
	if (wf.setFormatByStr(format) < 0)
		return false;
	return SmartArrayImpl<WordFormat, 8>::add(wf);
}

WordFormat *CommandFormat::begin()
{
	return SmartArrayImpl<WordFormat, 8>::begin();
}

WordFormat *CommandFormat::end()
{
	return SmartArrayImpl<WordFormat, 8>::end();
}

bool CommandFormat::setFormatByStr(const char *format, unsigned char index)
{
	WordFormat wf;
	unsigned int i = 0;
	while (format[i] != '\0') {
		int result = wf.setFormatByStr(format);
		if (result < 0)
			return false;
		else
			i += result;
	}
	return true;
}
